<template>
  <div class="container-content">
    <el-form
      ref="elForm"
      :model="formObject"
      label-width="100px"
      :rules="rules"
      status-icon
      label-position="left"
    >
      <el-collapse v-model="activeName" @change="handleClick">
        <el-collapse-item title="供应商编码" name="code">
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="创建组织" prop="createDept">
                <el-input v-model="formObject.createDept">
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="openDialog('org')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="使用组织" prop="useDept">
                <el-input v-model="formObject.useDept" disabled></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="注册编码" prop="registerCode">
                <el-input v-model="formObject.registerCode" disabled></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="编码" prop="supplierCode">
                <el-input v-model="formObject.supplierCode"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="名称" prop="supplierName">
                <el-input v-model="formObject.supplierName"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="简称" prop="forShort">
                <el-input v-model="formObject.forShort"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-collapse-item>
        <el-collapse-item title="基本信息" name="basic">
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="国家" prop="nationId">
                <el-select
                  v-model="formObject.nationId"
                  placeholder="请选择国家"
                  style="width: 100%"
                  @change="changeNation"
                >
                  <el-option
                    v-for="item in nationData"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="地区" prop="provincesId">
                <el-select
                  v-model="formObject.provincesId"
                  placeholder="请选择地区"
                  style="width: 100%"
                >
                  <el-option
                    v-for="item in provincesData"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="通讯地址" prop="mailingAddress">
                <el-input v-model="formObject.mailingAddress"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="邮政编码" prop="zipCode">
                <el-input v-model="formObject.zipCode"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="语言" prop="language">
                <el-select
                  v-model="formObject.language"
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="item in languageOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="公司网址" prop="companyWebsite">
                <el-input v-model="formObject.companyWebsite"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="行业" prop="industry">
                <el-select
                  v-model="formObject.industry"
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="item in industryOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="创立日期" prop="establishDate">
                <el-date-picker
                  v-model="formObject.establishDate"
                  type="datetime"
                  placeholder="选择日期"
                  style="width: 100%"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  format="yyyy-MM-dd HH:mm:ss"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="法人代表" prop="legalRepresentative">
                <el-input v-model="formObject.legalRepresentative"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="注册资金" prop="registeredCapital">
                <el-input
                  v-model="formObject.registeredCapital"
                  placeholder="万元"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="工商登记号" prop="registrationNumber">
                <el-input v-model="formObject.registrationNumber"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label="生产经营许可证"
                prop="productionLicense"
                label-width="120px"
              >
                <el-input v-model="formObject.productionLicense"></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="注册地址" prop="companyRegisteredAddress">
                <el-input
                  v-model="formObject.companyRegisteredAddress"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label="统一社会信用代码"
                prop="creditCode"
                label-width="130px"
              >
                <el-input v-model="formObject.creditCode"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="负责部门" prop="chargeDept">
                <el-input v-model="formObject.chargeDept">
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="openDialog('dept')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="负责人" prop="chargePerson">
                <el-input v-model="formObject.chargePerson">
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="openDialog('person')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="供应商分类" prop="classification">
                <el-select
                  v-model="formObject.classification"
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="item in classificationOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="供应类别" prop="supplyCategory">
                <el-input v-model="formObject.supplyCategory"> </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="供应商等级" prop="level">
                <el-select
                  v-model="formObject.level"
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="item in levelOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="供应商分组" prop="group">
                <el-input v-model="formObject.group">
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="openDialog('group')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="公司类别" prop="companyCategory">
                <el-select
                  v-model="formObject.companyCategory"
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="item in companyCategoryOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="公司性质" prop="companyNature">
                <el-select
                  v-model="formObject.companyNature"
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="item in companyNatureOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="公司规模" prop="companySize">
                <el-select
                  v-model="formObject.companySize"
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="item in companySizeOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="对应组织" prop="correspondingOrganization">
                <el-input
                  v-model="formObject.correspondingOrganization"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                label="对应集团供应商"
                prop="groupSupplier"
                label-width="140px"
              >
                <el-input v-model="formObject.groupSupplier">
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="openDialog('supplier')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-collapse-item>
        <el-collapse-item title="商务信息" name="business">
          <el-row :gutter="20">
            <el-col :span="6">
              <el-form-item label="采购组" prop="purchaseGroup">
                <el-input v-model="formObject.purchaseGroup">
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="openDialog('purchase')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="默认价目表" prop="defaultPriceList">
                <el-input v-model="formObject.defaultPriceList">
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="openDialog('price')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="业务状态" prop="businessState">
                <el-input v-model="formObject.businessState"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="默认折扣表" prop="defaultDiscount">
                <el-input v-model="formObject.defaultDiscount">
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="openDialog('discount')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="冻结范围" prop="freezeScope">
                <el-input v-model="formObject.freezeScope"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="供货方" prop="supply">
                <el-input v-model="formObject.supply">
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="openDialog('supply')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="冻结人" prop="freezingPerson">
                <el-input v-model="formObject.freezingPerson"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="汇总公司" prop="summaryCompany">
                <el-input v-model="formObject.summaryCompany">
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="openDialog('summary')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="冻结日期" prop="freezeDate">
                <el-date-picker
                  v-model="formObject.freezeDate"
                  type="datetime"
                  placeholder="选择日期"
                  style="width: 100%"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  format="yyyy-MM-dd HH:mm:ss"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="保证金比例" prop="ensureRate">
                <el-input
                  v-model="formObject.ensureRate"
                  placeholder="%"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="默认联系人" prop="defaultContracts">
                <el-input v-model="formObject.defaultContracts"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="6">
              <el-form-item label="VMI仓库" prop="vmiWarehouse">
                <el-input
                  :disabled="!formObject.isVmi"
                  v-model="formObject.vmiWarehouse"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="VMI业务" prop="isVmi">
                <el-checkbox v-model="formObject.isVmi" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="启用供应商协同"
                prop="enableCoordination"
                label-width="110px"
              >
                <el-checkbox v-model="formObject.enableCoordination" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-collapse-item>
        <el-collapse-item title="其他信息" name="other">
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="创建人" prop="userId">
                <el-input v-model="formObject.userId"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="审核人" prop="examineId">
                <el-input v-model="formObject.examineId"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="禁用人" prop="disabledId">
                <el-input v-model="formObject.disabledId"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="创建日期" prop="establishDate">
                <el-date-picker
                  v-model="formObject.establishDate"
                  type="datetime"
                  placeholder="选择日期"
                  style="width: 100%"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  format="yyyy-MM-dd HH:mm:ss"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="审核日期" prop="examineTime">
                <el-date-picker
                  v-model="formObject.examineTime"
                  type="datetime"
                  placeholder="选择日期"
                  style="width: 100%"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  format="yyyy-MM-dd HH:mm:ss"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="禁用日期" prop="disabledDate">
                <el-date-picker
                  v-model="formObject.disabledDate"
                  type="datetime"
                  placeholder="选择日期"
                  style="width: 100%"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  format="yyyy-MM-dd HH:mm:ss"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="修改人" prop="changeId">
                <el-input v-model="formObject.changeId"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="数据状态" prop="dataState">
                <el-input v-model="formObject.dataState"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="禁用状态" prop="disabledState">
                <el-input v-model="formObject.disabledState"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="修改日期" prop="changeTime">
                <el-date-picker
                  v-model="formObject.changeTime"
                  type="datetime"
                  placeholder="选择日期"
                  style="width: 100%"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  format="yyyy-MM-dd HH:mm:ss"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
        </el-collapse-item>
        <el-collapse-item title="财务信息" name="financial">
          <el-row :gutter="20">
            <el-col :span="6">
              <el-form-item label="对应客户" prop="correspondingCustomer">
                <el-input v-model="formObject.correspondingCustomer">
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="openDialog('customer')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="单次预付额度" prop="singlePrepaymentLimit">
                <el-input v-model="formObject.singlePrepaymentLimit"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="发票类型" prop="invoiceType">
                <el-select
                  v-model="formObject.invoiceType"
                  filterable
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="item in invoiceTypeOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="结算币别" prop="balanceCurrency">
                <el-input v-model="formObject.balanceCurrency">
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="openDialog('currency')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="税分类" prop="taxType">
                <el-select
                  v-model="formObject.taxType"
                  filterable
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="item in taxTypeOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="默认税率" prop="defaultTax">
                <el-input v-model="formObject.defaultTax">
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="openDialog('tax')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="结算方式" prop="balanceMethod">
                <el-input v-model="formObject.balanceMethod">
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="openDialog('balance')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="税务登记号" prop="taxNumber">
                <el-input v-model="formObject.taxNumber"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="付款条件" prop="paymentTerms">
                <el-input v-model="formObject.paymentTerms">
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="openDialog('payment')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="经营类型" prop="manageType">
                <el-select
                  v-model="formObject.manageType"
                  filterable
                  placeholder="请选择"
                  style="width: 100%"
                >
                  <el-option
                    v-for="item in manageTypeOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="结算方" prop="balanceParty">
                <el-input v-model="formObject.balanceParty">
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="openDialog('party')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="收款方" prop="payee">
                <el-input v-model="formObject.payee">
                  <i
                    slot="suffix"
                    class="el-input__icon el-icon-notebook-2"
                    style="cursor: pointer"
                    @click="openDialog('payee')"
                  ></i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="描述" prop="desc">
                <el-input v-model="formObject.desc" type="textarea"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-table
            :data="formObject.banks"
            style="width: 100%"
            highlight-current-row
            border
          >
            <template #empty>
              <el-button plain type="primary" round @click="addNewRow('banks')"
                >添加新行
              </el-button>
            </template>
            <el-table-column label="操作" width="120">
              <template slot-scope="scope">
                <el-button
                  plain
                  icon="el-icon-plus"
                  size="mini"
                  @click="handleDataAdd_banks(scope.$index, scope.row)"
                ></el-button>
                <el-button
                  plain
                  icon="el-icon-minus"
                  size="mini"
                  @click="handleDataDelete(scope.$index, scope.row, 'banks')"
                ></el-button>
              </template>
            </el-table-column>
            <el-table-column label="开户国家">
              <template slot-scope="scope">
                <el-form-item
                  prop="openingCountry"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    v-model="scope.row.openingCountry"
                    clearable
                  ></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="账户名称">
              <template slot-scope="scope">
                <el-form-item
                  prop="accountName"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    v-model="scope.row.accountName"
                    clearable
                  ></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <!--  -->
            <el-table-column label="收款银行">
              <template slot-scope="scope">
                <el-form-item
                  prop="dueBanke"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.dueBanke" clearable></el-input>
                </el-form-item>
                <!-- @change="
                                        positionChange(
                                            scope.row.position,
                                            scope.$index
                                        )
                                    " -->
              </template>
            </el-table-column>
            <el-table-column label="网点名称">
              <template slot-scope="scope">
                <el-form-item
                  prop="brancheName"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    v-model="scope.row.brancheName"
                    clearable
                  ></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="银行网点">
              <template slot-scope="scope">
                <el-form-item
                  prop="bankBranches"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.bankBranches"></el-input>
                </el-form-item>
              </template>
            </el-table-column>

            <el-table-column label="开户行地址">
              <template slot-scope="scope">
                <el-form-item
                  prop="openBankAddress"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    v-model="scope.row.openBankAddress"
                    clearable
                  ></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="开户银行">
              <template slot-scope="scope">
                <el-form-item
                  prop="bankName"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.bankName" clearable></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="银联号">
              <template slot-scope="scope">
                <el-form-item
                  prop="unionPayAccount"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    v-model="scope.row.unionPayAccount"
                    clearable
                  ></el-input>
                </el-form-item>
              </template>
            </el-table-column>

            <el-table-column label="币别">
              <template slot-scope="scope">
                <el-form-item
                  prop="currency"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.currency" clearable></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="默认">
              <template slot-scope="scope">
                <el-form-item
                  prop="isDefault"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-radio-group v-model="scope.row.isDefault">
                    <el-checkbox v-model="scope.row.isDefault" />
                  </el-radio-group>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="描述">
              <template slot-scope="scope">
                <el-form-item prop="desc" label-width="0px" style="margin: 0">
                  <el-input v-model="scope.row.desc" clearable></el-input>
                </el-form-item>
              </template>
            </el-table-column>
          </el-table>
        </el-collapse-item>
        <el-collapse-item title="联系人" name="more">
          <el-table
            :data="formObject.contracts"
            style="width: 100%"
            highlight-current-row
            border
          >
            <template #empty>
              <el-button
                plain
                type="primary"
                round
                @click="addNewRow('contracts')"
                >添加新行
              </el-button>
            </template>
            <el-table-column label="操作" width="120">
              <template slot-scope="scope">
                <el-button
                  plain
                  icon="el-icon-plus"
                  size="mini"
                  @click="handleDataAdd(scope.$index, scope.row)"
                ></el-button>
                <el-button
                  plain
                  icon="el-icon-minus"
                  size="mini"
                  @click="
                    handleDataDelete(scope.$index, scope.row, 'contracts')
                  "
                ></el-button>
              </template>
            </el-table-column>
            <el-table-column label="编码">
              <template slot-scope="scope">
                <el-form-item prop="code" label-width="0px" style="margin: 0">
                  <el-input v-model="scope.row.code"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="联系人" width="150">
              <template slot-scope="scope">
                <el-form-item prop="name" label-width="0px" style="margin: 0">
                  <el-input v-model="scope.row.name"> </el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="性别">
              <template slot-scope="scope">
                <el-form-item prop="sex" label-width="0px" style="margin: 0">
                  <el-select
                    v-model="scope.row.sex"
                    placeholder="请选择"
                    style="width: 100%"
                  >
                    <el-option key="0" label="男" value="0"></el-option>
                    <el-option key="1" label="女" value="1"></el-option>
                    <el-option key="2" label="未知" value="2"></el-option>
                  </el-select>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="职位">
              <template slot-scope="scope">
                <el-form-item
                  prop="position"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.position"></el-input>
                  <!-- @change="
                                        positionChange(
                                            scope.row.position,
                                            scope.$index
                                        )
                                    " -->
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="电话">
              <template slot-scope="scope">
                <el-form-item
                  prop="workTel"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.workTel" clearable></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="手机">
              <template slot-scope="scope">
                <el-form-item prop="mobile" label-width="0px" style="margin: 0">
                  <el-input v-model="scope.row.mobile"></el-input>
                </el-form-item>
              </template>
            </el-table-column>

            <el-table-column label="邮箱">
              <template slot-scope="scope">
                <el-form-item prop="email" label-width="0px" style="margin: 0">
                  <el-input v-model="scope.row.email" clearable></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="传真">
              <template slot-scope="scope">
                <el-form-item prop="fax" label-width="0px" style="margin: 0">
                  <el-input v-model="scope.row.fax" clearable></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="电子邮箱">
              <template slot-scope="scope">
                <el-form-item prop="email" label-width="0px" style="margin: 0">
                  <el-input v-model="scope.row.email" clearable></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="默认联系人">
              <template slot-scope="scope">
                <el-form-item
                  prop="isDefault"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-radio-group v-model="scope.row.isDefault">
                    <el-checkbox v-model="scope.row.isDefault" />
                  </el-radio-group>
                </el-form-item>
              </template>
            </el-table-column>

            <el-table-column label="所属公司">
              <template slot-scope="scope">
                <el-form-item
                  prop="belongCompany"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input
                    v-model="scope.row.belongCompany"
                    clearable
                  ></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="详细地址">
              <template slot-scope="scope">
                <el-form-item
                  prop="address"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.address" clearable></el-input>
                </el-form-item>
              </template>
            </el-table-column>
          </el-table>
        </el-collapse-item>
        <el-collapse-item title="组织信息" name="org">
          <el-table
            :data="formObject.organizations"
            style="width: 100%"
            highlight-current-row
            border
          >
            <template #empty>
              <el-button plain type="primary" round @click="addNewRow('org')"
                >添加新行
              </el-button>
            </template>
            <el-table-column label="操作" width="120">
              <template slot-scope="scope">
                <el-button
                  plain
                  icon="el-icon-plus"
                  size="mini"
                  @click="handleDataAdd_org(scope.$index, scope.row)"
                ></el-button>
                <el-button
                  plain
                  icon="el-icon-minus"
                  size="mini"
                  @click="handleDataDelete(scope.$index, scope.row, 'org')"
                ></el-button>
              </template>
            </el-table-column>
            <el-table-column label="编码">
              <template slot-scope="scope">
                <el-form-item
                  prop="locationCode"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.locationCode"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="地点名称">
              <template slot-scope="scope">
                <el-form-item
                  prop="locationName"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.locationName"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="联系人">
              <template slot-scope="scope">
                <el-form-item
                  prop="contractsName"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.contractsName">
                    <i
                      slot="suffix"
                      class="el-input__icon el-icon-notebook-2"
                      style="cursor: pointer"
                      @click="openDialog('contracts', scope.$index)"
                    ></i>
                  </el-input>
                </el-form-item>
              </template>
            </el-table-column>

            <el-table-column label="通讯地址">
              <template slot-scope="scope">
                <el-form-item
                  prop="mailingAddress"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.mailingAddress"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="启用">
              <template slot-scope="scope">
                <el-form-item
                  prop="isEnable"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-radio-group v-model="scope.row.isEnable">
                    <el-checkbox v-model="scope.row.isEnable" />
                  </el-radio-group>
                </el-form-item>
              </template>
            </el-table-column>

            <el-table-column label="电话">
              <template slot-scope="scope">
                <el-form-item
                  prop="workTel"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-input v-model="scope.row.workTel" clearable></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="手机">
              <template slot-scope="scope">
                <el-form-item prop="mobile" label-width="0px" style="margin: 0">
                  <el-input v-model="scope.row.mobile"></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="传真">
              <template slot-scope="scope">
                <el-form-item prop="fax" label-width="0px" style="margin: 0">
                  <el-input v-model="scope.row.fax" clearable></el-input>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="电子邮箱">
              <template slot-scope="scope">
                <el-form-item prop="email" label-width="0px" style="margin: 0">
                  <el-input v-model="scope.row.email" clearable></el-input>
                </el-form-item>
              </template>
            </el-table-column>

            <el-table-column label="备注">
              <template slot-scope="scope">
                <el-form-item prop="remark" label-width="0px" style="margin: 0">
                  <el-input v-model="scope.row.remark" clearable></el-input>
                </el-form-item>
              </template>
            </el-table-column>

            <el-table-column label="默认供货地址">
              <template slot-scope="scope">
                <el-form-item
                  prop="isDefaultSupply"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-radio-group v-model="scope.row.isDefaultSupply">
                    <el-checkbox v-model="scope.row.isDefaultSupply" />
                  </el-radio-group>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="默认开票地址">
              <template slot-scope="scope">
                <el-form-item
                  prop="isDefaultInvoicing"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-radio-group v-model="scope.row.isDefaultInvoicing">
                    <el-checkbox v-model="scope.row.isDefaultInvoicing" />
                  </el-radio-group>
                </el-form-item>
              </template>
            </el-table-column>
            <el-table-column label="默认收款地址">
              <template slot-scope="scope">
                <el-form-item
                  prop="isDefaultPayment"
                  label-width="0px"
                  style="margin: 0"
                >
                  <el-radio-group v-model="scope.row.isDefaultPayment">
                    <el-checkbox v-model="scope.row.isDefaultPayment" />
                  </el-radio-group>
                </el-form-item>
              </template>
            </el-table-column>
          </el-table>
        </el-collapse-item>
      </el-collapse>
    </el-form>
    <!-- 弹窗 -->
    <el-dialog
      :title="dialogTitle"
      :visible.sync="open"
      append-to-body
      width="50%"
      destroy-on-close
    >
      <!-- 创建组织 -->
      <el-table
        v-loading="loading"
        v-if="dialogType === 'org'"
        ref="orgTable"
        :data="orgData"
        @selection-change="selectItems"
      >
        <el-table-column type="selection" width="55" align="center">
        </el-table-column>
        <el-table-column prop="deptName" label="部门名称"></el-table-column>
        <el-table-column prop="phone" label="手机号码"></el-table-column>
        <el-table-column prop="email" label="邮箱"></el-table-column>
        <el-table-column prop="createBy" label="创建人"></el-table-column>
        <el-table-column prop="leader" label="负责人"></el-table-column>
        <el-table-column prop="createTime" label="创建时间"></el-table-column>
      </el-table>
      <!-- 负责部门 -->
      <el-table
        v-loading="loading"
        v-if="dialogType === 'dept'"
        ref="deptTable"
        :data="deptData"
        @selection-change="selectItem"
      >
        <el-table-column type="selection" width="55" align="center">
        </el-table-column>
        <el-table-column prop="deptName" label="部门名称"></el-table-column>
        <el-table-column prop="phone" label="手机号码"></el-table-column>
        <el-table-column prop="email" label="邮箱"></el-table-column>
        <el-table-column prop="createBy" label="创建人"></el-table-column>
        <el-table-column prop="leader" label="负责人"></el-table-column>
        <el-table-column prop="createTime" label="创建时间"></el-table-column>
      </el-table>
      <!-- 负责人 -->
      <el-table
        v-loading="loading"
        v-if="dialogType === 'person'"
        ref="personTable"
        :data="personData"
        @selection-change="selectItems"
      >
        <el-table-column type="selection" width="55" align="center">
        </el-table-column>
        <el-table-column
          prop="dept.deptName"
          label="部门名称"
        ></el-table-column>
        <el-table-column
          prop="userName"
          label="用户名称"
          width="120"
        ></el-table-column>
        <el-table-column prop="staffStatus" label="员工状态">
          <template slot-scope="scope">
            <span v-if="scope.row.staffStatus === 1">实习</span>
            <span v-if="scope.row.staffStatus === 2">试用期</span>
            <span v-if="scope.row.staffStatus === 3">已转正</span>
            <span v-if="scope.row.staffStatus === 4">试用不合格</span>
            <span v-if="scope.row.staffStatus === 5">已辞退</span>
            <span v-if="scope.row.staffStatus === 6">自愿离职</span>
            <span v-if="scope.row.staffStatus === 7">黑名单</span>
            <span v-else>--</span>
          </template>
        </el-table-column>
        <el-table-column prop="dept.leader" label="负责人"></el-table-column>
        <el-table-column prop="sex" label="性别">
          <template slot-scope="scope">
            <span v-if="scope.row.sex === 1">男</span>
            <span v-if="scope.row.sex === 2">女</span>
            <span v-else>--</span>
          </template>
        </el-table-column>
        <el-table-column prop="status" label="帐号状态">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.status === '0'" type="success">正常</el-tag>
            <el-tag v-if="scope.row.status === '1'" type="danger">停用</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          prop="phonenumber"
          label="联系电话"
          width="120"
        ></el-table-column>
        <el-table-column
          prop="idCard"
          label="身份证号码"
          width="160"
        ></el-table-column>
        <el-table-column
          prop="address"
          label="联系地址"
          width="240"
        ></el-table-column>
        <el-table-column
          prop="email"
          label="邮箱"
          width="180"
        ></el-table-column>
      </el-table>
      <!-- 供应商分组 -->
      <el-table
        v-loading="loading"
        v-if="dialogType === 'group'"
        ref="supplyTable"
        :data="groupData"
        @selection-change="selectItems"
      >
        <el-table-column type="selection" width="55" align="center">
        </el-table-column>
        <el-table-column prop="name" label="名称"></el-table-column>
        <el-table-column
          prop="userId"
          label="创建人"
          width="120"
        ></el-table-column>
        <el-table-column prop="parentId" label="父级"></el-table-column>
        <el-table-column prop="describe" label="描述"></el-table-column>
      </el-table>
      <!-- 对应集团供应商 供货方 汇总公司 收款方 结算方 -->
      <el-table
        v-loading="loading"
        v-if="
          dialogType === 'supplier' ||
          dialogType === 'supply' ||
          dialogType === 'summary' ||
          dialogType === 'payee' ||
          dialogType === 'party'
        "
        ref="supplyTable"
        :data="supplyData"
        @selection-change="selectItems"
      >
        <el-table-column type="selection" width="55" align="center">
        </el-table-column>
        <el-table-column
          prop="supplierCode"
          label="	供应商编码"
        ></el-table-column>
        <el-table-column
          prop="supplierName"
          label="供应商名称"
        ></el-table-column>
        <el-table-column prop="group" label="供应商分组"></el-table-column>
        <el-table-column
          prop="classification"
          label="供应商分类"
        ></el-table-column>
        <el-table-column prop="level" label="供应商等级"> </el-table-column>
        <el-table-column
          prop="defaultContracts"
          label="默认联系人"
        ></el-table-column>
      </el-table>
      <!-- 采购组 -->
      <el-table
        v-loading="loading"
        v-if="dialogType === 'purchase'"
        ref="purchaseTable"
        :data="purchaseData"
        @selection-change="selectItems"
      >
        <el-table-column type="selection" width="55" align="center">
        </el-table-column>
        <el-table-column
          prop="businessGroupType"
          label="业务组"
        ></el-table-column>
        <el-table-column
          prop="userId"
          label="创建人"
          width="120"
        ></el-table-column>
        <el-table-column prop="describe" label="描述"></el-table-column>
      </el-table>
      <!-- 默认价目表 默认折扣表 -->
      <el-table
        v-loading="loading"
        v-if="dialogType === 'price' || dialogType === 'discount'"
        ref="priceTable"
        :data="priceData"
        @selection-change="selectItems"
      >
        <el-table-column type="selection" width="55" align="center">
        </el-table-column>
        <el-table-column prop="code" label="编码"></el-table-column>
        <el-table-column prop="name" label="名称"></el-table-column>
        <el-table-column prop="extraTax" label="价外税"></el-table-column>
        <el-table-column prop="priceType" label="价格类型"></el-table-column>
        <el-table-column prop="type" label="类型">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.type === 0">价目表</el-tag>
            <el-tag v-if="scope.row.type === 1">折扣表</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="includingTax" label="是否含税">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.includingTax" type="success">是</el-tag>
            <el-tag v-if="!scope.row.includingTax" type="danger">否</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="isDefault" label="是否默认">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.isDefault" type="success">是</el-tag>
            <el-tag v-if="!scope.row.isDefault" type="danger">否</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="isTemp" label="是否暂存">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.isTemp" type="success">是</el-tag>
            <el-tag v-if="!scope.row.isTemp" type="danger">否</el-tag>
          </template>
        </el-table-column>
      </el-table>
      <!-- 对应客户 -->
      <el-table
        v-loading="loading"
        v-if="dialogType === 'customer'"
        ref="customerTable"
        :data="customerData"
        @selection-change="selectItems"
      >
        <el-table-column type="selection" width="55" align="center">
        </el-table-column>
        <el-table-column prop="customerName" label="客户名称">
        </el-table-column>
        <el-table-column
          prop="customerAttributeId"
          label="客户属性"
        ></el-table-column>
        <el-table-column prop="telPhone" label="电话"></el-table-column>
        <el-table-column prop="companyId" label="上级公司"></el-table-column>
        <el-table-column prop="provincesId" label="省"></el-table-column>
        <el-table-column prop="address" label="详细地址"></el-table-column>
        <el-table-column prop="remarks" label="备注"></el-table-column>
        <el-table-column prop="createTime" label="创建日期"></el-table-column>
      </el-table>
      <!-- 默认税率 -->
      <el-table
        v-loading="loading"
        v-if="dialogType === 'tax'"
        ref="taxTable"
        :data="taxData"
        @selection-change="selectItems"
      >
        <el-table-column
          type="selection"
          width="55"
          align="center"
        ></el-table-column>

        <el-table-column prop="rateCode" label="编码"></el-table-column>
        <el-table-column prop="title" label="名称"></el-table-column>
        <el-table-column prop="deptId" label="所属公司"></el-table-column>
        <el-table-column prop="rate" label="税率"></el-table-column>
        <el-table-column prop="dataStatus" label="数据状态">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.dataStatus === 1">创建</el-tag>
            <el-tag v-else-if="scope.row.dataStatus === 2">审核中</el-tag>
            <el-tag v-else-if="scope.row.dataStatus === 3">已审核</el-tag>
            <span v-else>--</span>
          </template>
        </el-table-column>
        <el-table-column prop="isAddTax" label="是否增值税">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.isAddTax === 1" type="success">是</el-tag>
            <el-tag v-else-if="scope.row.isAddTax === 2" type="danger"
              >否</el-tag
            >
            <span v-else>--</span>
          </template>
        </el-table-column>
        <el-table-column prop="isBuyReplace" label="买方代扣代缴">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.isBuyReplace === 1" type="success"
              >是</el-tag
            >
            <el-tag v-else-if="scope.row.isBuyReplace === 2" type="danger"
              >否</el-tag
            >
            <span v-else>--</span>
          </template>
        </el-table-column>
        <el-table-column prop="isSellReplace" label="卖方代扣代缴">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.isSellReplace === 1" type="success"
              >是</el-tag
            >
            <el-tag v-else-if="scope.row.isSellReplace === 2" type="danger"
              >否</el-tag
            >
            <span v-else>--</span>
          </template>
        </el-table-column>
        <el-table-column prop="isTaxInvoice" label="是否开增值税发票">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.isTaxInvoice === 1" type="success"
              >是</el-tag
            >
            <el-tag v-else-if="scope.row.isTaxInvoice === 2" type="danger"
              >否</el-tag
            >
            <span v-else>--</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="effectiveTime"
          label="生效日期"
        ></el-table-column>
        <el-table-column prop="invalidTime" label="失效日期"></el-table-column>
      </el-table>
      <!-- 结算方式 -->
      <el-table
        v-loading="loading"
        v-if="dialogType === 'balance'"
        ref="balanceTable"
        :data="balanceData"
        @selection-change="selectItems"
      >
        <el-table-column
          type="selection"
          width="55"
          align="center"
        ></el-table-column>
        <el-table-column prop="bizCode" label="编码"></el-table-column>
        <el-table-column prop="title" label="名称"></el-table-column>
        <el-table-column prop="isDefault" label="是否为默认结算方式">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.isDefault === 1" type="success">是</el-tag>
            <el-tag v-else-if="scope.row.isDefault === 2" type="danger"
              >否</el-tag
            >
            <span v-else>--</span>
          </template>
        </el-table-column>
        <el-table-column prop="isDisabled" label="是否禁用">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.isDisabled === 1" type="danger">是</el-tag>
            <el-tag v-else-if="scope.row.isDisabled === 2" type="success"
              >否</el-tag
            >
            <span v-else>--</span>
          </template>
        </el-table-column>
        <el-table-column prop="isSupportLinePay" label="是否支持网银付款">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.isSupportLinePay === 1" type="success"
              >是</el-tag
            >
            <el-tag v-else-if="scope.row.isSupportLinePay === 2" type="danger"
              >否</el-tag
            >
            <span v-else>--</span>
          </template>
        </el-table-column>
        <el-table-column prop="isPayFee" label="是否支付手续费">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.isPayFee === 1" type="success">是</el-tag>
            <el-tag v-else-if="scope.row.isPayFee === 2" type="danger"
              >否</el-tag
            >
            <span v-else>--</span>
          </template>
        </el-table-column>
      </el-table>
      <!-- 结算币别 -->
      <el-table
        v-loading="loading"
        v-if="dialogType === 'currency'"
        ref="currencyTable"
        :data="currencyData"
        @selection-change="selectItems"
      >
        <el-table-column
          type="selection"
          width="55"
          align="center"
        ></el-table-column>
        <el-table-column prop="currencyName" label="币别名称"></el-table-column>
        <el-table-column
          prop="currencySymbol"
          label="货币代码"
        ></el-table-column>
        <el-table-column prop="code" label="币别编码"></el-table-column>
        <el-table-column
          prop="amountAccuracy"
          label="金额精度"
        ></el-table-column>
        <el-table-column prop="dataStatus" label="数据状态">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.dataStatus === 1">创建</el-tag>
            <el-tag v-else-if="scope.row.dataStatus === 2">审核中</el-tag>
            <el-tag v-else-if="scope.row.dataStatus === 3">已审核</el-tag>
            <span v-else>--</span>
          </template>
        </el-table-column>
        <el-table-column prop="isDisabled" label="是否禁用">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.isDisabled === 1" type="danger">是</el-tag>
            <el-tag v-else-if="scope.row.isDisabled === 2" type="success"
              >否</el-tag
            >
            <span v-else>--</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="priceAccuracy"
          label="单价精度"
        ></el-table-column>
        <el-table-column prop="showFlag" label="单据显示货币符号">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.showFlag === 1" type="success">是</el-tag>
            <el-tag v-else-if="scope.row.showFlag === 2" type="danger"
              >否</el-tag
            >
            <span v-else>--</span>
          </template>
        </el-table-column>
      </el-table>
      <!-- 联系人 -->
      <el-table
        v-loading="loading"
        v-if="dialogType === 'contracts'"
        ref="contractsTable"
        :data="contractsData"
        @selection-change="selectItems"
      >
        <el-table-column type="selection" width="55" align="center">
        </el-table-column>
        <el-table-column prop="name" label="姓名"></el-table-column>
        <el-table-column
          prop="contactsCode"
          label="联系人编码"
        ></el-table-column>
        <el-table-column prop="position" label="职务"></el-table-column>
        <el-table-column prop="sex" label="性别">
          <template slot-scope="scope">
            <span v-if="scope.row.sex === '1'">男</span>
            <span v-if="scope.row.sex === '2'">女</span>
            <span v-else>未知</span>
          </template>
        </el-table-column>
        <el-table-column prop="supplierId" label="供应商"></el-table-column>
        <el-table-column prop="workTel" label="固定电话"></el-table-column>
        <el-table-column prop="mobile" label="移动电话"></el-table-column>
        <el-table-column prop="fax" label="传真"></el-table-column>
        <el-table-column prop="email" label="邮件地址"></el-table-column>
        <el-table-column
          prop="belongCompany"
          label="所属公司"
        ></el-table-column>
        <el-table-column prop="addressName" label="地点名称"></el-table-column>
        <el-table-column prop="address" label="详细地址"></el-table-column>
        <el-table-column prop="userId" label="创建人"></el-table-column>
        <el-table-column prop="isDefault" label="是否默认联系人">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.isDefault" type="success">是</el-tag>
            <el-tag v-else-if="!scope.row.isDefault" type="danger">否</el-tag>
          </template>
        </el-table-column>
      </el-table>
      <!-- 付款条件 -->
      <el-table
        v-loading="loading"
        v-if="dialogType === 'payment'"
        ref="paymentTable"
        :data="paymentData"
        @selection-change="selectItems"
      >
        <el-table-column type="selection" width="55" align="center">
        </el-table-column>
        <!-- <el-table-column prop="id" label="id"> </el-table-column> -->
        <el-table-column prop="conditionCode" label="编码"></el-table-column>
        <el-table-column prop="title" label="名称"></el-table-column>
        <el-table-column prop="deptId" label="所属公司"></el-table-column>

        <el-table-column prop="type" label="类型">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.dueSetStandard === 1">收款条件</el-tag>
            <el-tag v-if="scope.row.dueSetStandard === 2">付款条件</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="dueSetStandard" label="到期日设置标准">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.dueSetStandard === 1">按比例</el-tag>
            <el-tag v-if="scope.row.dueSetStandard === 2">按金额</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="dueTime" label="到期日计算日期">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.dueSetStandard === 1">订单日期</el-tag>
            <el-tag v-if="scope.row.dueSetStandard === 2"
              >应收单业务日期</el-tag
            >
            <el-tag v-if="scope.row.dueSetStandard === 3">出库日期</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="receiptType" label="收款方式">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.dueSetStandard === 1">按到期日收款</el-tag>
            <el-tag v-if="scope.row.dueSetStandard === 2">按订单收款</el-tag>
            <el-tag v-if="scope.row.dueSetStandard === 3"
              >按物料明细收款</el-tag
            >
          </template>
        </el-table-column>
        <el-table-column prop="conditionDesc" label="描述"></el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button @click="cancelSelect">取 消</el-button>
        <el-button type="primary" @click="confirmSelect">确 定</el-button>
      </span>
      <el-pagination
        class="pagination mt10"
        background
        layout="total, sizes, prev, pager, next, jumper"
        :total="dialogTotal * 1"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :page-sizes="[10, 15, 20, 25]"
        :current-page="currentPage"
        :page-size="pageSize"
      >
      </el-pagination>
    </el-dialog>
  </div>
</template>
<script>
import { listDept } from "@/api/system/dept";
import { getAreaList } from "@/api/area/area";
import { listUser } from "@/api/system/user";
import {
  getGroupData,
  getPurchaseData,
  getPriceData,
  getTaxData,
  getSettleData,
  getPayData,
  getCurrencyData,
  getSupplyContact,
  add,
} from "@/api/base/data";
import { getSupplyList } from "@/api/system/supply";
import { getList } from "@/api/system/customer";
export default {
  data() {
    return {
      activeName: [
        "code",
        "basic",
        "business",
        "other",
        "financial",
        "more",
        "org",
      ],
      open: false,
      loading: true,
      dialogType: "",
      counties: [],
      pageSize: 10,
      currentPage: 1,
      dialogTitle: "",
      listIndex: 0,
      selectItem: [],
      orgData: [], //创建组织弹窗列表
      deptData: [], //部门弹窗列表
      personData: [], //负责人弹窗列表
      groupData: [], //供应商弹窗列表
      supplyData: [], //对应集团供应商 供货方 汇总公司 弹窗列表
      purchaseData: [], //采购组弹窗列表
      priceData: [], //默认价目表 默认折扣表 弹窗列表
      customerData: [], //对应客户表 弹窗列表
      taxData: [], //默认税率 弹窗列表
      balanceData: [], //结算方式 弹窗列表
      currencyData: [], //结算币别 弹窗列表
      contractsData: [], //联系人 弹窗列表
      paymentData: [], //付款条件 弹窗列表

      dialogTotal: "", //创建组织弹窗分页
      formObject: {
        balanceCurrency: "",
        balanceCurrencyName: "",
        balanceMethod: "",
        balanceParty: "",
        banks: [],
        businessState: "",
        changeId: "",
        changeTime: "",
        chargeDept: "",
        chargePerson: "",
        cityId: "",
        classification: "",
        companyCategory: "",
        companyNature: "",
        companyRegisteredAddress: "",
        companySize: "",
        companyWebsite: "",
        contracts: [],
        correspondingCustomer: "",
        correspondingOrganization: "",
        countyId: "",

        createDept: "",
        createTime: "",
        creditCode: "",
        dataState: "",
        defaultContracts: "",
        defaultDiscount: "",
        defaultPriceList: "",
        defaultTax: "",
        desc: "",
        disabledDate: "",
        disabledId: "",
        disabledState: "",
        enableCoordination: false,
        ensureRate: "",
        establishDate: "",
        examineId: "",
        examineTime: "",
        forShort: "",
        freezeDate: "",
        freezeScope: "",
        freezingPerson: "",
        group: "",
        groupSupplier: "",
        id: "",
        industry: "",
        invoiceType: "",
        isVmi: false,
        language: "",
        legalRepresentative: "",
        level: "",
        mailingAddress: "",
        manageType: "",
        nationId: "",
        organizations: [],
        payee: "",
        paymentTerms: "",
        productionLicense: "",
        provincesId: "",
        provincesName: "",
        purchaseGroup: "",
        registerCode: "",
        registeredCapital: "",
        registrationNumber: "",
        singlePrepaymentLimit: "",
        summaryCompany: "",
        supplierCode: "",
        supplierName: "",
        supply: "",
        supplyCategory: "",
        taxNumber: "",
        taxType: "",
        useDept: "",
        userId: "",
        vmiWarehouse: "",
        zipCode: "",
      },
      // 组织信息
      orgObj: {
        changeTime: "",
        contractsId: "",
        contractsName: "",
        createTime: "",
        email: "",
        fax: "",
        id: "",
        isDefaultInvoicing: true,
        isDefaultPayment: true,
        isDefaultSupply: true,
        isEnable: true,

        locationCode: "",
        locationName: "",
        mailingAddress: "",
        phone: "",
        remark: "",
        supplierId: "",
        tel: "",
        userId: "",
      },
      // 联系人
      contractsObj: {
        address: "",
        addressCode: "",
        addressName: "",
        belongCompany: "",
        changeTime: "",
        contactsCode: "",
        createTime: "",
        email: "",
        fax: "",
        id: "",
        isDefault: true,

        mobile: "",
        name: "",
        position: "",
        sex: "",
        supplierId: "",
        type: "",
        userId: "",
        workTel: "",
      },
      // 银行
      banksObj: {
        accountName: "",
        addAndTel: "",
        bankAccount: "",
        bankBranches: "",
        bankName: "",
        brancheName: "",
        changeTime: "",
        createBy: "",
        createTime: "",
        currency: "",
        desc: "",
        dueBanke: "",
        id: "",
        invoicingCompanyName: "",
        isDefault: "",

        openBankAddress: "",
        openingCountry: "",
        params: {},
        relationId: "",
        remark: "",
        searchValue: "",
        swiftCode: "",
        taxId: "",
        type: 0,
        unionPayAccount: "",
        updateBy: "",
        updateTime: "",
      },
      //发票类型
      invoiceTypeOptions: [
        {
          value: "1",
          label: "增值说专业用票",
        },
        {
          value: "2",
          label: "普通发票",
        },
      ],
      // 语言
      languageOptions: [
        {
          value: "1",
          label: "中文",
        },
        {
          value: "2",
          label: "英文",
        },
      ],
      // 行业
      industryOptions: [
        {
          value: "1",
          label: "选项一",
        },
        {
          value: "2",
          label: "选项二",
        },
      ],
      // 供应商分类
      classificationOptions: [
        {
          value: "1",
          label: "选项一",
        },
        {
          value: "2",
          label: "选项二",
        },
      ],
      // 供应商等级
      levelOptions: [
        {
          value: "1",
          label: "选项一",
        },
        {
          value: "2",
          label: "选项二",
        },
      ],
      // 公司类别
      companyCategoryOptions: [
        {
          value: "1",
          label: "选项一",
        },
        {
          value: "2",
          label: "选项二",
        },
      ],
      // 公司性质
      companyNatureOptions: [
        {
          value: "1",
          label: "选项一",
        },
        {
          value: "2",
          label: "选项二",
        },
      ],
      // 公司规模
      companySizeOptions: [
        {
          value: "1",
          label: "选项一",
        },
        {
          value: "2",
          label: "选项二",
        },
      ],
      // 税分类
      taxTypeOptions: [
        {
          value: "1",
          label: "选项一",
        },
        {
          value: "2",
          label: "选项二",
        },
      ],
      // 经营类型
      manageTypeOptions: [
        {
          value: "1",
          label: "选项一",
        },
        {
          value: "2",
          label: "选项二",
        },
      ],
      rules: {
        createDept: [
          { required: true, message: "请输入组织", trigger: "blur" },
        ],
        useDept: [
          {
            required: true,
            message: "请输入使用组织",
            trigger: "blur",
          },
        ],
        supplierName: [
          { required: true, message: "请输入名称", trigger: "blur" },
        ],
        balanceCurrency: [
          {
            required: true,
            message: "请输入结算币别",
            trigger: "blur",
          },
        ],
        // customerName: [
        //   { required: true, message: "客户名称不能为空！", trigger: "blur" },
        // ],
        // name: [
        //   { required: true, message: "联系人姓名不能为空！", trigger: "blur" },
        // ],
      },
      nationData: [], // 国家下拉
      provincesData: [], // 地区下拉
    };
  },
  methods: {
    // 页签切换事件
    handleClick(tab, event) {
      console.log(tab, event);
    },
    // 附件上传
    handleFileChange() {
      console.log("文件上传");
    },

    // 基础表单提交
    submitForm(cb) {
      this.$refs["elForm"].validate((valid) => {
        if (!valid) {
          this.$message.error("请完整填写信息！");
          return;
        }
        // TODO 提交表单
        add(this.formObject, "Supplier").then((res) => {
          if (res.code === 200) {
            cb();
            this.$message.success("新增成功");
          }
        });
      });
    },
    // 基础表单取消
    formRest(basicFormRef) {
      this.$refs[basicFormRef].resetFields();
    },
    // 联系人表单 添加行
    handleDataAdd() {
      if (this.formObject.contracts == undefined) {
        this.formObject.contracts = [];
      }
      let obj = {
        address: "",
        addressCode: "",
        addressName: "",
        belongCompany: "",
        changeTime: "",
        contactsCode: "",
        createTime: "",
        email: "",
        fax: "",
        id: "",
        isDefault: true,

        mobile: "",
        name: "",
        position: "",
        sex: "",
        supplierId: "",
        type: "",
        userId: "",
        workTel: "",
      };
      this.formObject.contracts.push(obj);
    },
    // 删除行
    handleDataDelete(index, row, type) {
      this.$confirm("请确认是否要删除此行？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
          if (type == "org") {
            this.formObject.organizations.splice(index, 1);
          } else if (type == "banks") {
            this.formObject.banks.splice(index, 1);
          } else {
            this.formObject.contracts.splice(index, 1);
          }
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    //银行信息表单 添加行
    handleDataAdd_banks() {
      if (this.formObject.banks == undefined) {
        this.formObject.banks = [];
      }
      let obj = {
        accountName: "",
        addAndTel: "",
        bankAccount: "",
        bankBranches: "",
        bankName: "",
        brancheName: "",
        changeTime: "",
        createBy: "",
        createTime: "",
        currency: "",
        desc: "",
        dueBanke: "",
        id: "",
        invoicingCompanyName: "",
        isDefault: "",

        openBankAddress: "",
        openingCountry: "",
        params: {},
        relationId: "",
        remark: "",
        searchValue: "",
        swiftCode: "",
        taxId: "",
        type: 0,
        unionPayAccount: "",
        updateBy: "",
        updateTime: "",
      };
      this.formObject.banks.push(obj);
    },

    //组织表单 添加行
    handleDataAdd_org() {
      if (this.formObject.organizations == undefined) {
        this.formObject.organizations = [];
      }
      let obj = {
        changeTime: "",
        contractsId: "",
        contractsName: "",
        createTime: "",
        email: "",
        fax: "",
        id: "",
        isDefaultInvoicing: true,
        isDefaultPayment: true,
        isDefaultSupply: true,
        isEnable: true,

        locationCode: "",
        locationName: "",
        mailingAddress: "",
        phone: "",
        remark: "",
        supplierId: "",
        tel: "",
        userId: "",
      };
      this.formObject.organizations.push(obj);
    },

    //添加新行
    addNewRow(type) {
      if (type === "org") {
        this.handleDataAdd_org();
      } else if (type === "banks") {
        this.handleDataAdd_banks();
      } else {
        this.handleDataAdd();
      }
    },

    // 创建组织 弹窗
    selectOrg() {
      this.dialogTitle = "选择组织";
      let level = 1;
      listDept({ level }).then((res) => {
        if (res.code === 200) {
          this.loading = false;
          this.orgData = res.data;
          this.dialogTotal = res.data.length;
        }
        return;
      });
    },

    // 国家弹窗
    getNation() {
      let parentId = 0;
      getAreaList({ parentId }).then((res) => {
        if (res.code === 200) {
          this.nationData = res.rows.map((item) => {
            return {
              value: item.id,
              label: item.areaName,
            };
          });
        }
      });
    },
    // 选择国家
    changeNation(val) {
      if (val) {
        let level = 1;
        getAreaList({ level }).then((res) => {
          if (res.code === 200) {
            this.provincesData = res.rows.map((item) => {
              return {
                value: item.id,
                label: item.areaName,
              };
            });
          }
        });
      }
    },
    //负责部门 弹窗
    selectDept() {
      this.dialogTitle = "选择部门";
      let level = 2;
      listDept({ level }).then((res) => {
        if (res.code === 200) {
          this.loading = false;
          this.deptData = res.data;
          this.dialogTotal = res.data.length;
        }
        return;
      });
    },
    // 负责人 弹窗
    selectPerson() {
      this.dialogTitle = "选择负责人";
      this.open = true;
      this.loading = true;
      let pageSize = this.pageSize;
      let pageNum = this.currentPage;
      listUser({ pageSize, pageNum }).then((res) => {
        this.loading = false;
        this.personData = res.rows;
        this.dialogTotal = res.total;
      });
    },
    // 供应商分组 弹窗
    selectGroup() {
      this.dialogTitle = "选择供应商分组";
      getGroupData().then((res) => {
        this.loading = false;
        this.groupData = res.rows;
        this.dialogTotal = res.total;
      });
    },

    // 采购组 弹窗
    selectPurchase() {
      this.dialogTitle = "选择采购组";
      getPurchaseData().then((res) => {
        this.loading = false;
        this.purchaseData = res.rows;
        this.dialogTotal = res.total;
      });
    },
    // 默认价目表 默认折扣表
    selectPrice() {
      let type = null;
      // 处理弹出框标题
      const typeArray = {
        price: () => {
          this.dialogTitle = "选择默认价目";
          type = 0;
        },
        discount: () => {
          this.dialogTitle = "选择默认折扣";
          type = 1;
        },
      };
      typeArray[this.dialogType] ? typeArray[this.dialogType]() : "";
      getPriceData({ type }).then((res) => {
        this.loading = false;
        this.priceData = res.rows;
        this.dialogTotal = res.total;
      });
    },
    // 对应集团供应商 供货方 汇总公司  收款方 结算方
    selectSupply() {
      // 处理弹出框标题
      const typeArray = {
        supplier: () => {
          this.dialogTitle = "选择对应集团供应商";
        },
        supply: () => {
          this.dialogTitle = "选择供货方";
        },
        summary: () => {
          this.dialogTitle = "选择汇总公司";
        },
        payee: () => {
          this.dialogTitle = "选择收款方";
        },
        party: () => {
          this.dialogTitle = "选择结算方";
        },
      };
      typeArray[this.dialogType] ? typeArray[this.dialogType]() : "";
      getSupplyList().then((res) => {
        this.loading = false;
        this.supplyData = res.rows;
        this.dialogTotal = res.total;
      });
    },
    // 对应客户
    selectCustomer() {
      this.dialogTitle = "选择客户";
      getList().then((res) => {
        this.loading = false;
        this.customerData = res.rows;
        this.dialogTotal = res.total;
      });
    },
    // 默认税率
    selectTax() {
      this.dialogTitle = "选择税率";
      getTaxData().then((res) => {
        this.loading = false;
        this.taxData = res.rows;
        this.dialogTotal = res.total;
      });
    },
    // 付款条件
    selectPayment() {
      this.dialogTitle = "选择付款条件";
      getPayData().then((res) => {
        this.loading = false;
        this.paymentData = res.rows;
        this.dialogTotal = res.total;
      });
    },
    // 结算方式
    selectBalance() {
      this.dialogTitle = "选择结算方式";
      getSettleData().then((res) => {
        this.loading = false;
        this.balanceData = res.rows;
        this.dialogTotal = res.total;
      });
    },
    // 结算币别
    selectBalance() {
      this.dialogTitle = "选择结算币别";
      getCurrencyData().then((res) => {
        this.loading = false;
        this.currencyData = res.rows;
        this.dialogTotal = res.total;
      });
    },
    // 联系人
    selectContracts() {
      this.dialogTitle = "选择联系人";
      getSupplyContact().then((res) => {
        this.loading = false;
        this.contractsData = res.rows;
        this.dialogTotal = res.total;
      });
    },
    // 分页 当前页改变事件
    handleCurrentChange(val) {
      this.currentPage = val;
      this.refresh();
    },
    // 分页 每页条数改变事件
    handleSizeChange(val) {
      this.pageSize = val;
      this.refresh();
    },
    // 打开弹窗
    openDialog(val, index) {
      this.open = true;
      this.loading = true;
      this.dialogType = val;
      this.listIndex = index;
      this.refresh();
    },
    // 选择item
    selectItems(val) {
      this.selectItem = val;
    },
    // 弹窗取消按钮
    cancelSelect() {
      this.open = false;
      this.selectItem = [];
    },
    // 弹窗确定按钮
    confirmSelect() {
      this.refresh(this.selectItem);
    },
    // 处理请求
    refresh(val) {
      const nameMap = {
        org: () => {
          if (val) {
            if (val.length > 1) {
              this.$message.error("请选择一条记录！");
              return;
            }
            this.formObject.createDept = val[0].deptName;
            this.formObject.useDept = val[0].deptName;
            this.open = false;
          } else {
            this.selectOrg();
          }
        },
        dept: () => {
          if (val) {
            this.formObject.chargeDept = val[0].deptName;
          } else {
            this.selectDept();
          }
        },
        person: () => {
          if (val) {
            this.formObject.chargePerson = val[0].dept.leader;
          } else {
            this.selectPerson();
          }
        },
        group: () => {
          if (val) {
            this.formObject.group = val[0].name;
          } else {
            this.selectGroup();
          }
        },
        supplier: () => {
          if (val) {
            this.formObject.groupSupplier = val[0].groupSupplier;
          } else {
            this.selectSupply();
          }
        },
        purchase: () => {
          if (val) {
            this.formObject.purchaseGroup = val[0].businessGroupType;
          } else {
            this.selectPurchase();
          }
        },
        price: () => {
          if (val) {
            this.formObject.defaultPriceList = val[0].name;
          } else {
            this.selectPrice();
          }
        },
        supply: () => {
          if (val) {
            this.formObject.supply = val[0].supply;
          } else {
            this.selectSupply();
          }
        },
        summary: () => {
          if (val) {
            this.formObject.summaryCompany = val[0].summaryCompany;
          } else {
            this.selectSupply();
          }
        },
        discount: () => {
          if (val) {
            this.formObject.defaultDiscount = val[0].name;
          } else {
            this.selectPrice();
          }
        },
        customer: () => {
          if (val) {
            this.formObject.correspondingCustomer = val[0].customerName;
          } else {
            this.selectCustomer();
          }
        },
        payee: () => {
          if (val) {
            this.formObject.payee = val[0].payee;
          } else {
            this.selectSupply();
          }
        },
        tax: () => {
          if (val) {
            this.formObject.defaultTax = val[0].rate;
          } else {
            this.selectTax();
          }
        },
        payment: () => {
          if (val) {
            this.formObject.paymentTerms = val[0].title;
          } else {
            this.selectPayment();
          }
        },
        balance: () => {
          if (val) {
            this.formObject.balanceMethod = val[0].title;
          } else {
            this.selectBalance();
          }
        },
        currency: () => {
          if (val) {
            this.formObject.balanceCurrencyName = val[0].currencyName;
            this.formObject.balanceCurrency = val[0].code;
          } else {
            this.selectBalance();
          }
        },
        party: () => {
          if (val) {
            this.formObject.balanceParty = val[0].balanceParty;
          } else {
            this.selectSupply();
          }
        },
        contracts: () => {
          if (val) {
            this.formObject.organizations[this.listIndex].contractsId =
              val[0].userId;
            this.formObject.organizations[this.listIndex].contractsName =
              val[0].name;
          } else {
            this.selectContracts();
          }
        },
      };
      nameMap[this.dialogType] ? nameMap[this.dialogType]() : "";
    },
  },
  created() {
    // 查询国家
    this.getNation();
  },
};
</script>
<style lang="scss" scoped>
// .add {
//   padding: 15px;
// }
.panel-title {
  font-size: 18px;
  color: #37474f;
  font-weight: 500;
  text-shadow: rgba(0, 0, 0, 0.15) 0 0 1px;
}

::v-deep .el-form-item__content {
  margin-left: 0;
}

.main-responsible {
  font-size: 14px;
  font-weight: 550;
  color: #263238;
  position: relative;
  text-indent: 15px;
}
</style>
